using MES_workbench.Domian.Customers;
using MES_workbench.ErrorCode;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using WebApplication1.Implement.IServices;

namespace WebApplication1.Controllers
{
    /// <summary>
    /// 数据看板控制器
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    public class CustomerController : ControllerBase
    {
        private readonly ICustomerServices _customerServices;
        private readonly ILogger<CustomerController> _logger;

        /// <summary>
        /// 构造函数注入服务与日志
        /// </summary>
        public CustomerController(ICustomerServices customerServices, ILogger<CustomerController> logger)
        {
            _customerServices = customerServices;
            _logger = logger;
        }

        /// <summary>
        /// 获取工单工序明细数据列表
        /// </summary>
        /// <returns>工单工序明细列表</returns>
        [HttpGet("workorderprocesses")]
        [ProducesResponseType(typeof(ApiResult<List<WorkOrderProcess>>), StatusCodes.Status200OK)]
        public ActionResult<ApiResult<List<WorkOrderProcess>>> GetWorkOrderProcesses()
        {
            _logger.LogInformation("[GET] /api/customer/workorderprocesses 调用");
            var result = _customerServices.GetWorkOrderProcesses();
            return Ok(result);
        }

        /// <summary>
        /// 获取工单数据列表
        /// </summary>
        /// <returns>工单列表</returns>
        [HttpGet("workorders")]
        [ProducesResponseType(typeof(ApiResult<List<WorkOrder>>), StatusCodes.Status200OK)]
        public ActionResult<ApiResult<List<WorkOrder>>> GetWorkOrders()
        {
            _logger.LogInformation("[GET] /api/customer/workorders 调用");
            var result = _customerServices.GetWorkOrders();
            return Ok(result);
        }

        /// <summary>
        /// 获取报工数据列表
        /// </summary>
        /// <returns>报工列表</returns>
        [HttpGet("workreports")]
        [ProducesResponseType(typeof(ApiResult<List<WorkReport>>), StatusCodes.Status200OK)]
        public ActionResult<ApiResult<List<WorkReport>>> GetWorkReports()
        {
            _logger.LogInformation("[GET] /api/customer/workreports 调用");
            var result = _customerServices.GetWorkReports();
            return Ok(result);
        }
    }
}
